package com.itrencai.String;

import java.util.Scanner;

public class Register {
    public static void main(String[] args) {
        //1.定义正确的用户名和密码
        String okname="itrencai";
        String okpassword="123456";
        Scanner sc=new Scanner(System.in);
        for (int i = 1; i <=3; i++) {
            System.out.println("请输入用户名：");
            String name=sc.next();
            System.out.println("请输入密码：");
            String password=sc.next();
            //判断登录是否成功
            if(okname.equals(name)){
                if(okpassword.equals(password)){
                    System.out.println("登录成功！");
                    break;
                }else{
                    System.out.println("密码错误！您还剩余"+(3-i)+"次机会");
                }
            }else{
                System.out.println("登录名错误！您还剩余"+(3-i)+"次机会");
            }





        }
    }



}
